Skip to content

Issue 3211 fix flaky tests part 3 - #3355

Merged
sosnovsky merged 17 commits into
masterfrom
issue_3211_fix_flaky_tests_part_3
Nov 25, 2026
Merged

sosnovsky merged 17 commits into
masterfrom
issue_3211_fix_flaky_tests_part_3

Conversation

@DenBond7

@DenBond7 DenBond7 commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

This PR fixes more flaky instrumentation tests that fail on slow CI emulators (part 3, follows #3340 and #3347), re-enables the ones disabled as flaky, and fixes an app bug found on the way.

App fix

  • AccountAliasesViewModel.fetchUpdates() fetched the Gmail aliases (sendAs) for the account from getActiveAccountSuspend(), but saved them with activeAccountLiveData.value. That LiveData gets its value asynchronously (after withDecryptedInfo()). If the API response came first, updateAliases(null, ...) silently saved nothing, so the alias signatures were missing in the compose screen on a slow device. Now the aliases are saved for the same account they were fetched for. AccountAliasesViewModelTest reproduces it deterministically (the LiveData isn't observed, so it has no value) and fails without the fix.

CI

  • ci-wait-for-emulator.sh sets hide_error_dialogs. Right after boot a slow emulator can report an ANR even for system_server, and then "Process system isn't responding" comes back for the whole job. The dialog takes the window focus, so ~15 unrelated tests of a shard failed with RootViewWithoutFocusException.

Fixed tests

Most fixes replace Thread.sleep() and one-time checks with waits for an observable state, and use replaceText() instead of typeText().

  • AttachmentDownloadingWithRestrictionFlowTest#testDownloadingAttachment: re-enabled. Waits for the "download complete" notification instead of a fixed sleep. The mock web server holds the attachment until the test checks the "downloading" dialog (the dialog closes itself after the download).
  • MessagesListChangeGmailLabelsFlowTest#testLabelsManagement: waits until the labels dialog is loaded, for the batchModify request and for the database update. Uses useCommonIdling = false.
  • MessageDetailsChangeGmailLabelsFlowTest#testLabelsManagement: re-enabled. Waits for the labels on the screen and in the dialog, and checks the batchModify request in the test thread (an assertion in the mock dispatcher didn't fail the test).
  • ComposeScreen{NewMessage,Reply,Forward}WithGmailApiSignatureFlowTest#testAddingSignatureAfterStart: re-enabled. Wait for the signature text instead of a fixed sleep.
  • MessageDetailsFlowTest: re-enabled testFwdButton, testSignedMsgClearSign and 5 testSignatureVerification... tests. testPgpBadges waits for the final badge types: while the sender's key is looked up, the list already has the final count with VERIFYING_SIGNATURE.
  • ImportRecipientAllowAttesterSearchOnlyForDomainsFlowTest#testAllowAttesterSearchOnlyForDomains: re-enabled. Both tests of the class also check the Attester requests recorded by the mock web server, not only the text on the screen.
  • CheckCredentialsFragmentInIsolationTest#testReturnExceptionForFailedAuthorization: re-enabled. Both tests wait for the fragment result instead of reading it right away, and the failed authorization test checks that the cause is AuthenticationFailedException.
  • SignInScreenFlowTest#testUseGmail: waits up to 30 s for the Google Sign-in screen. On a slow emulator the Google Play services UI process can be frozen, and UiAutomator sees the new window later.

Test infrastructure

  • BaseTest.waitUntilViewMatches() polls a view with its own failure handler (no screenshot per failed check) and fails with a regular Espresso error at the end.
  • docs/testing-like-ci.md: the new emulator setup and the system_server ANR symptom.

issue #3211


Tests (delete all except exactly one):

  • Tests added or updated

To be filled by reviewers

I have reviewed that this PR... (tick whichever items you personally focused on during this review):

  • addresses the issue it closes (if any)
  • code is readable and understandable
  • is accompanied with tests, or tests are not needed
  • is free of vulnerabilities

@DenBond7
DenBond7 marked this pull request as ready for review November 24, 2026 18:23
@DenBond7
DenBond7 requested a review from sosnovsky as a code owner November 24, 2026 18:23
@DenBond7 DenBond7 mentioned this pull request Nov 24, 2026
32 of 52 tasks

@sosnovsky sosnovsky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good 👍

@sosnovsky
sosnovsky merged commit 5e93494 into master Nov 25, 2026
8 checks passed
@sosnovsky
sosnovsky deleted the issue_3211_fix_flaky_tests_part_3 branch November 25, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants